//
//  SearchViewController.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/22.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "SearchViewController.h"

@interface SearchViewController ()

@end

@implementation SearchViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self loadSubviewsOnSearchView];
}


//
- (void)loadSubviewsOnSearchView{
    // 自定义导航栏
    UIView *topView = [[UIView alloc]init];
    topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(NaviH);
    }];
    
    UIView *searchInput = [[UIView alloc]init];
    searchInput.backgroundColor = KLColor_C1;
    searchInput.layer.masksToBounds = YES;
    searchInput.layer.cornerRadius = 16*HEIGHT;
    [topView addSubview:searchInput];
    [searchInput mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(topView).offset(15*WIDTH);
        make.width.mas_equalTo(298*WIDTH);
        make.height.mas_equalTo(32*HEIGHT);
        make.bottom.equalTo(topView).offset(-5*HEIGHT);
    }];
    
    UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [searchBtn setBackgroundImage:[UIImage imageNamed:@"sousuo_icon_sousuo"] forState:UIControlStateNormal];
    [searchInput addSubview:searchBtn];
    [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(searchInput);
        make.width.height.mas_equalTo(16*WIDTH);
        make.left.equalTo(searchInput).offset(10*WIDTH);
    }];
    
    UITextField *inputTF = [[UITextField alloc]init];
    inputTF.placeholder = @"输入搜索内容...";
    inputTF.textColor = KLColor_B6;
    inputTF.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
    [searchInput addSubview:inputTF];
    [inputTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(searchInput);
        make.left.equalTo(searchBtn.mas_right).offset(8*WIDTH);
        make.right.equalTo(searchInput);
    }];
    
    
    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:KLColor_B6 forState:UIControlStateNormal];
    cancelBtn.titleLabel.font= [UIFont fontWithName:@"PingFangSC-Regular" size:16*WIDTH];
    [topView addSubview:cancelBtn];
    [[cancelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(searchInput);
        make.right.equalTo(topView).offset(-15*WIDTH);
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
